﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Core;

namespace Yuanlin.Business
{
    public class MyCompanyShop : YuanlinUserControl
    {
        protected Repeater list;
        protected Pager pager;
        protected CurrentPage currentPage;

        protected override void OnLoad(EventArgs e)
        {
            BindData();
        }

        private void BindData()
        {
            YuanlinUser yuanlinUser = UserManager.GetUser(UserIdFromGreenNum) as YuanlinUser;
            if (yuanlinUser == null)
                return;
            CompanyShopListRequest request = new CompanyShopListRequest();
            request.UserId = yuanlinUser.EntityId.Value;
            request.PageIndex = pager.PageIndex;
            request.PageSize = pager.PageSize;
            EntityList companyShops = BusinessManager.GetCompanyShopList(RequestHelper.BuildGetCompanyShopListRequest(request));

            list.DataSource = companyShops;
            list.DataBind();

            if (pager != null && currentPage != null)
            {
                pager.TotalPages = pager.CalculateTotalPages(companyShops.TotalCount);
                currentPage.TotalRecords = (companyShops.TotalCount);
                currentPage.TotalPages = pager.TotalPages;
                currentPage.PageIndex = pager.PageIndex;
            }
        }
    }
}
